package 程序员面试金典;

import org.junit.Test;

import java.util.LinkedList;
import java.util.List;

public class 多次搜索 {

    public int[][] multiSearch(String big, String[] smalls) {
        int[][] ints = new int[smalls.length][];
        List<List<Integer>> lists = new LinkedList<List<Integer>>();
        for (String small : smalls) {
            if (small.length()==0)
                continue;
            List<Integer> list = new LinkedList<>();
            int len=small.length();
            for (int i = 0; i <= big.length()-len; i++) {
                if (big.substring(i,i+len).equals(small))
                    list.add(i);
            }
            lists.add(list);
        }
        if (lists.size()==0)
            return new int[1][0];
        for (int i = 0; i < smalls.length; i++) {
            ints[i]=lists.get(i).stream().mapToInt(Integer::intValue).toArray();
        }
        return ints;
    }
    @Test
    public void test(){
        String[] a = {""};
        System.out.println(a[0]);
    }
}
